﻿Imports System.Data.SqlClient
Public Class dbProductionPriceStock
    Dim Var As New varDeclare

    Public Function GetBaseList(OnlyMinus As Boolean) As DataSet
        Dim connection As SqlConnection
        Dim adapter As SqlDataAdapter
        Dim command As New SqlCommand
        Dim ds As New DataSet
        Dim Filter As String = ""
        If (OnlyMinus) Then
            If (Filter.Length = 0) Then
                Filter = " WHERE "
            Else : Filter = Filter + " AND "
            End If
            Filter = Filter + "Actual < 0"
        End If
        connection = New SqlConnection(Var.SUISConn)
        connection.Open()
        command.Connection = connection
        command.CommandType = CommandType.Text
        command.CommandText = "SELECT * FROM vPriceListDelivered" + Filter
        adapter = New SqlDataAdapter(command)
        adapter.Fill(ds)
        connection.Close()
        Return ds
    End Function

    Public Function GetPOList(groups As String, code As String) As DataSet
        Dim connection As SqlConnection
        Dim adapter As SqlDataAdapter
        Dim command As New SqlCommand
        Dim ds As New DataSet
        connection = New SqlConnection(Var.SUISConn)
        connection.Open()
        command.Connection = connection
        command.CommandType = CommandType.Text
        command.CommandText = "SELECT * FROM vOpenPOList WHERE groups = @groups AND code = @code"
        command.Parameters.Add("@groups", SqlDbType.VarChar).Value = groups
        command.Parameters.Add("@code", SqlDbType.VarChar).Value = code
        adapter = New SqlDataAdapter(command)
        adapter.Fill(ds)
        connection.Close()
        Return ds
    End Function

    Public Function GetSOList(groups As String, code As String) As DataSet
        Dim connection As SqlConnection
        Dim adapter As SqlDataAdapter
        Dim command As New SqlCommand
        Dim ds As New DataSet
        connection = New SqlConnection(Var.SUISConn)
        connection.Open()
        command.Connection = connection
        command.CommandType = CommandType.Text
        command.CommandText = "SELECT * FROM vOpenSOList WHERE groups = @groups AND code = @code"
        command.Parameters.Add("@groups", SqlDbType.VarChar).Value = groups
        command.Parameters.Add("@code", SqlDbType.VarChar).Value = code
        adapter = New SqlDataAdapter(command)
        adapter.Fill(ds)
        connection.Close()
        Return ds
    End Function
End Class
